package dahuiji.regist.service;

import java.util.List;

import dahuiji.common.dao.BaceDao;
import dahuiji.common.entity.User;

/**
 * 注册功能的service
 * 
 * @author 张鑫
 * 
 */
public class RegistService {
	private BaceDao baceDao;

	/**
	 * 保存
	 * 
	 * @param u
	 * @return
	 */
	public Long save(User u) {
		System.out.println("UUUUU"+u.getName());
		baceDao = new BaceDao();
		return baceDao.save(u);
	}

	/**
	 * 检测这个用户名是否已经被占用 返回true被用，然后false没被用
	 * 
	 * @param name
	 * @return
	 */
	public boolean checkName(String name) {
		String sql = "select u.user_name from tb_dahuiji_user u where u.user_name="
				+ "'" + name + "'";
		baceDao = new BaceDao();
		List list = baceDao.executeQuerySql(sql);
		if (list.size() == 1) {
			return true;
		}
		return false;
	}
	/**
	 * 检测邮箱是否已经被注册
	 * @param eamil
	 * @return
	 */
	public boolean checkEmail(String eamil) {
		String sql = "select u.email from tb_dahuiji_user u where u.email="
				+ "'" + eamil + "'";
		baceDao = new BaceDao();
		List list = baceDao.executeQuerySql(sql);
		if (list.size() == 1) {
			return true;
		}
		return false;
	}

}
